﻿using System;
using Avalonia.Data;

namespace KinonekoSoftware.Foundation.UX.Controls
{
    public class RarityRibbon : ColorRibbon
    {
        public static readonly StyledProperty<int>    LevelProperty;
        public static readonly StyledProperty<IBrush> RarityStarColorProperty;

        public static readonly object[] L = new object[]
        {
            1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
        };

        static RarityRibbon()
        {
            LevelProperty           = AvaloniaProperty.Register<RarityRibbon, int>(nameof(Level), 1, false, BindingMode.OneWay, null, CoerceLevelValueCallback);
            RarityStarColorProperty = AvaloniaProperty.Register<RarityRibbon, IBrush>(nameof(RarityStarColor));
        }

        private static int CoerceLevelValueCallback(AvaloniaObject d, int value)
        {
            return Math.Clamp(value, 1, 12) - 1;
        }

        public IBrush RarityStarColor
        {
            get => GetValue(RarityStarColorProperty);
            set => SetValue(RarityStarColorProperty, value);
        }
        public int Level
        {
            get => (int)GetValue(LevelProperty);
            set => SetValue(LevelProperty, value);
        }
    }
}